
import java.util.Random;


public class StraightChasee implements Pursuit_Client.PursuitPlayer{

/**
 *  This chasee attempts to normalize its direction and speed up in that direction with a constant acceleration.
 *  This is is for testing purposes only.
 * @author Seth Shannin
 * @version 1.00 2008/12/5
 */
public StraightChasee(){}
	Random generator = new Random();
	
    double meX;
    double meY;
    double himX;
    double himY;
    double meXVel;
    double meYVel;
    double himXVel;
    double himYVel;
    double meTheta;
    double meAngVel;
    double himTheta;
    double himAngVel;
    //these are used to store the states from the previous time step
    double meX1;
    double meY1;
    double himX1;
    double himY1;
    double meXVel1;
    double meYVel1;
    double himXVel1;
    double himYVel1;
    double meTheta1;
    double meAngVel1;
    double himTheta1;
    double himAngVel1;
    
    public void update(	double a, double b, double c, double d, double e, double f, 
    					double g, double h, double i, double j, double k, double l) 
    {
    	//set the previous timestep variables
    	meX1=meX; meY1=meY; himX1=himX; himY1=himY; meXVel1=meXVel; meYVel1=meYVel; himXVel1=himXVel; himYVel1=himYVel;    
    		meTheta1=meTheta; meAngVel1=meAngVel; himTheta1=himTheta; himAngVel1=himAngVel;
    	//update state variables
    	meX=a; meY=b; himX=g; himY=h;meXVel=d; meYVel=e; himXVel=j; himYVel=k; meTheta=c; meAngVel=f; himTheta=i; himAngVel=l;
    }
    
    /**
     * 
     * @param angVel The current angular velocity.
     * @return A value for angular acceleration that will reduce the magnitude of the angular velocity
     */
    public double getReducingAngAcc(double angVel)
    {
    	if(angVel>=1)
    		return -1;
    	if (angVel<=-1)
    		return 1;
    	if (angVel>0)
    		return (-(Math.sqrt(angVel)));
    	else
    		return (Math.sqrt(Math.abs(angVel)));
    }
    
    public double getAcceleration() 
    {  	return .75;  }

    public double getAngularAcceleration() 
    {	return getReducingAngAcc(meAngVel);  }
    
    public String getRole() 
    {    return "chasee";    }
}

